package com.jack.leetcode.每日一题;

public class 最佳观光组合 {

    public static void main(String[] args) {
        int[] A = {8,1,5,2,6};
        System.out.println(maxScoreSightseeingPair(A));
    }

    public static int maxScoreSightseeingPair(int[] A) {
        int n = A.length;
        if(n == 0 || n == 1){
            return 0;
        }
        int max = 0;
        int pre_max = A[0] + 0;
        for(int i = 1;i < n;i++){
            max = Math.max(max, pre_max + A[i] - i);
            pre_max = Math.max(pre_max, A[i] + i);
        }
        return max;
    }
}
